package apigenerator;

import org.aspectj.weaver.tools.PointcutExpression;
import org.aspectj.weaver.tools.PointcutParser;
import org.springframework.core.annotation.Order;

/**
 * @author 1203056
 * @version Id: AspectjExpressionTypeFilter.java, v 0.1 2021-09-07 14:15 1203056 Exp $
 */
@Order(2)
public class AspectjExpressionTypeFilter implements TypeFilter {

    private PointcutParser pointcutParser     = PointcutParser
        .getPointcutParserSupportingSpecifiedPrimitivesAndUsingContextClassloaderForResolution(PointcutParser.getAllSupportedPointcutPrimitives());
    PointcutExpression     pointcutExpression = null;

    public AspectjExpressionTypeFilter() {
        //TODO 是否线程安全
        pointcutExpression = pointcutParser.parsePointcutExpression("execution(* apigenerator.*Facade.*(..))");
    }

    @Override
    public boolean match(Class<?> type) {
        return pointcutExpression.couldMatchJoinPointsInType(type);
    }
}
